********************************************************************************
/** Data for replication package

Paper Title: Unpacking gender discrepancies in academic promotion across STEM fields in Mexico

Authors: Lauren Lanahan; Claudia N. Gonzalez-Brambila; Daniel Armanios

Lead Author of Data Curation: Claudia N. Gonzalez-Brambila

Lead Author of Code/Analysis: Lauren Lanahan (llanahan@uoregon.edu)

Software: Stata 18; Microsoft Excel

Replication package includes:

[1] do file
	Data replication.do

[3] dta files
	Descriptive Data for replication.dta (Table 2; Fig 1; Fig 2; S1 Fig; S2 Fig)
	Trend Lines for replication.dta (Fig 3; Fig 4; S3 Fig; S4 Fig; S5 Fig; S6 Fig; S7 Fig; Fig 5)
	Data prep for replication.dta (S8 Fig)

[1] cvs file
	Excel for replication.csv (Fig 1; Fig 2; Fig 6; S8 Fig)
	
Comment: Code is organized in manner that reflects ordering of results presented in paper.
**/

global dir // set directory manually
*global dir "C:\Users\llanahan\Dropbox\SNI\_Overhaul\Replication Package\"
********************************************************************************
/* < Internal use only > Code to prep de-identified data.
clear all
set more off
use "$dir\Descriptive Data.dta"
keep exp male phdage dumphdmex dumphdeur dumphdusa dumphdother areadummy1 areadummy2 areadummy3 areadummy6 areadummy7 state_dichotomy largeinst age_L0 age_L1 age_L2 age_L3 asfaras_l0 asfaras_l1 asfaras_l2 asfaras_l3 year anycert asfaras_l0_f asfaras_l1_f asfaras_l2_f asfaras_l3_f asfaras_l0_m asfaras_l1_m asfaras_l2_m asfaras_l3_m level PANEL_L0 PANEL_L1 PANEL_L2 PANEL_L3 cum_pubs cum_cites male largeinst areadummy1 areadummy2 areadummy3 areadummy6 areadummy7 dumphd* portfolio* state match* asfaras* L0female_L1malereferet L1female_L2malereferet L2female_L3malereferet review_committee_male100pct review_committee_male95pct review_committee_male90pct year entryyear gender
egen researcher_id = group(exp)
drop exp
save "$dir\Descriptive Data for replication.dta", replace 
*/
********************************************************************************

	***************
	**  TABLE 2  **
	***************
{

* Note: This code reports overall descriptive detail and comparison of means. In addition, we post the Microsoft Excel file to illustrate the derivations of the data (Excel for replication.csv). Refer to tab <T2 F1 F2 F6>.

clear all
set more off
use "$dir\Descriptive Data for replication.dta"
preserve 
keep if year == 1981 & anycert == 1 // keep cross section for descriptive reporting purposes
global var male phdage dumphdmex dumphdeur dumphdusa dumphdother areadummy1 areadummy2 areadummy3 areadummy6 areadummy7 state_dichotomy largeinst age_L0 age_L1 age_L2 age_L3 asfaras_l0 asfaras_l1 asfaras_l2 asfaras_l3
estpost tabstat $var, statistics(count mean p50 p25 p75 sd min max) columns(statistics)
	set more off
	matrix m1=(1)
	matrix m2=(1)
	matrix m3=(1)
	matrix m4=(1)
	foreach x in $var {
	quietly ttest `x', by(male) unequal 
	matrix m1 = m1\(r(mu_1))
	matrix m2 = m2\(r(mu_2))
	matrix m3 = m3\(r(t))
	matrix m4 = m4\(r(p))
	}
	matrix q1 = (m1[2..22,1..1],m2[2..22,1..1],m3[2..22,1..1],m4[2..22,1..1])
	matrix colnames q1 = FEMALE MALE t-stat p-value
	matrix rownames q1 = male phdage dumphdmex dumphdeur dumphdusa dumphdother areadummy1 areadummy2 areadummy3 areadummy6 areadummy7 state_dichotomy largeinst age_L0 age_L1 age_L2 age_L3 asfaras_l0 asfaras_l1 asfaras_l2 asfaras_l3
	matrix drop m1 m2 m3 m4
	mat list q1
	count if male == 1
	count if male == 0
restore 
}
	
	*********************
	**  FIGURES 1 & 2  **
	*********************
{

* Note: This code reports raw statistics for producing pie and bar charts in Microsoft Excel. In addition, we post the excel file to illustrate the derivations of the data (Excel for replication.csv). Refer to tab <T2 F1 F2 F6>.

clear all
set more off
use "$dir\Descriptive Data for replication.dta"
preserve	
keep if year == 1981 & anycert == 1 // keep cross section for descriptive reporting purposes
foreach x in asfaras_l0_f asfaras_l1_f asfaras_l2_f asfaras_l3_f asfaras_l0_m asfaras_l1_m asfaras_l2_m asfaras_l3_m {
	count if `x' == 1
}
restore 
}

	***********************
	**  S1 & S2 FIGURES  **
	***********************
{

* Note: This code reports raw statistics for producing trend lines pie and bar charts in Microsoft Excel. In addition, we post the excel file to illustrate the derivations of the data (Excel for replication.csv). Refer to tab <S1F S2F>.

clear all
set more off
use "$dir\Descriptive Data for replication.dta"
* Compute Total
forvalues i = 1991(1)2011 {
preserve 
keep if level != . & year ==`i'
di `i'
count 
count if level == 0
count if level == 1
count if level == 2
count if level == 3
restore 
}

* Compute Female
forvalues i = 1991(1)2011 {
preserve 
keep if level != . & year ==`i'
drop if male == 1
di `i'
count 
count if level == 0
count if level == 1
count if level == 2
count if level == 3
restore 
}
}
	
	*************************************
	************ TREND LINES ************
	*************************************
{

* Note: For all trend lines, we adjust structure of data to report over standardized panel.

clear all
set more off
use "$dir\Descriptive Data for replication.dta"
foreach x in L0 L1 L2 L3 {
preserve 
keep PANEL_`x' cum_pubs cum_cites male largeinst areadummy1 areadummy2 areadummy3 areadummy6 areadummy7 dumphd* portfolio* state match* asfaras* L0female_L1malereferet L1female_L2malereferet L2female_L3malereferet review_committee_male100pct review_committee_male95pct review_committee_male90pct year entryyear 
keep if PANEL_`x' >= -5 & PANEL_`x' <= 5
gen level = "`x'"
rename PANEL_`x' PANEL
save "$dir\Data Prepped_`x'.dta", replace 
restore
}
clear all 
set more off
use "$dir\Data Prepped_L0.dta"
foreach x in L1 L2 L3 {
	append using "$dir\Data Prepped_`x'.dta"
}
save "$dir\Trend Lines for replication.dta", replace 
}

	************************************
	**  FIGURE 3 (Panel A & Panel B)  **
	************************************
{
clear all 
set more off 
use "$dir\Trend Lines for replication.dta"	
foreach x in cum_pubs cum_cites { // cum_pubs ~ PANEL A; cum_cites ~ PANEL B
preserve
bys PANEL: egen `x'_L0_post_m = mean(`x') if level == "L0" & PANEL >= 0 & male == 1
bys PANEL: egen `x'_L0_pre_m = mean(`x') if level == "L0" & PANEL < 0 & male == 1
bys PANEL: egen `x'_L1_post_m = mean(`x') if level == "L1" & PANEL >= 0 & male == 1
bys PANEL: egen `x'_L1_pre_m = mean(`x') if level == "L1" & PANEL < 0 & male == 1
bys PANEL: egen `x'_L2_post_m = mean(`x') if level == "L2" & PANEL >= 0 & male == 1
bys PANEL: egen `x'_L2_pre_m = mean(`x') if level == "L2" & PANEL < 0 & male == 1
bys PANEL: egen `x'_L3_post_m = mean(`x') if level == "L3" & PANEL >= 0 & male == 1
bys PANEL: egen `x'_L3_pre_m = mean(`x') if level == "L3" & PANEL < 0 & male == 1

bys PANEL: egen `x'_L0_post_f = mean(`x') if level == "L0" & PANEL >= 0 & male == 0
bys PANEL: egen `x'_L0_pre_f = mean(`x') if level == "L0" & PANEL < 0 & male == 0
bys PANEL: egen `x'_L1_post_f = mean(`x') if level == "L1" & PANEL >= 0 & male == 0
bys PANEL: egen `x'_L1_pre_f = mean(`x') if level == "L1" & PANEL < 0 & male == 0
bys PANEL: egen `x'_L2_post_f = mean(`x') if level == "L2" & PANEL >= 0 & male == 0
bys PANEL: egen `x'_L2_pre_f = mean(`x') if level == "L2" & PANEL < 0 & male == 0
bys PANEL: egen `x'_L3_post_f = mean(`x') if level == "L3" & PANEL >= 0 & male == 0
bys PANEL: egen `x'_L3_pre_f = mean(`x') if level == "L3" & PANEL < 0 & male == 0
sum `x'_L0_pre_m `x'_L1_pre_m `x'_L2_pre_m `x'_L3_pre_m `x'_L0_pre_f `x'_L1_pre_f `x'_L2_pre_f `x'_L3_pre_f if PANEL == -1
sum `x'_L0_post_m `x'_L1_post_m `x'_L2_post_m `x'_L3_post_m `x'_L0_post_f `x'_L1_post_f `x'_L2_post_f `x'_L3_post_f if PANEL == 5
twoway (lfit `x'_L3_pre_f PANEL, mcolor(green) lc(green) lpattern(line)) (lfit `x'_L3_post_f PANEL, mcolor(green) lc(green) lpattern(line)) (lfit `x'_L3_pre_m PANEL, mcolor(green) lc(green) lpattern(dash_dot))  (lfit `x'_L3_post_m PANEL, mcolor(green) lc(green) lpattern(dash_dot)) (lfit `x'_L2_pre_f PANEL, mcolor(maroon) lc(maroon) lpattern(line)) (lfit `x'_L2_post_f PANEL, mcolor(maroon) lc(maroon) lpattern(line)) (lfit `x'_L2_pre_m PANEL, mcolor(maroon) lc(maroon) lpattern(dash_dot)) (lfit `x'_L2_post_m PANEL, mcolor(maroon) lc(maroon) lpattern(dash_dot)) (lfit `x'_L1_pre_f PANEL, mcolor(blue) xline(0) lc(blue) legend(position(3)) lpattern(line)) (lfit `x'_L1_post_f PANEL, mcolor(blue) xline(0) lc(blue) lpattern(line)) (lfit `x'_L1_pre_m PANEL, mcolor(blue) xline(0) lc(blue) legend(position(3)) lpattern(dash)) (lfit `x'_L1_post_m PANEL, mcolor(blue) xline(0) lc(blue) lpattern(dash)) (lfit `x'_L0_pre_f PANEL, mcolor(black) lc(black) lpattern(line)) (lfit `x'_L0_post_f PANEL, mcolor(black) lc(black) lpattern(line)) (lfit `x'_L0_pre_m PANEL, mcolor(black) lc(black) lpattern(shortdash))  (lfit `x'_L0_post_m PANEL, mcolor(black) lc(black) lpattern(shortdash)) , legend(label(1 "F: Level 3") label(2 "F: Level 3") label(3 "M: Level 3") label(4 "M: Level 3") label(5 "F: Level 2") label(6 "F: Level 2") label(7 "M: Level 2") label(8 "M: Level 2") label(9 "F: Level 1") label(10 "F: Level 1") label(11 "M: Level 1") label(12 "M: Level 1") label(13 "F: Candidate") label(14 "F: Candidate") label(15 "M: Candidate") label(16 "M: Candidate")) ytitle("`x''") xtitle("Panel")
restore 
}
}

	************************************
	**  FIGURE 4 (Panel A & Panel B)  **
	************************************
{
clear all 
set more off 
use "$dir\Trend Lines for replication.dta"	
foreach x in cum_pubs cum_cites { // cum_pubs ~ PANEL A; cum_cites ~ PANEL B
preserve
bys PANEL: egen `x'_L0_post_m = mean(`x') if asfaras_l0 == 1 & PANEL >= 0 & male == 1
bys PANEL: egen `x'_L0_pre_m = mean(`x') if asfaras_l0 == 1 & PANEL < 0 & male == 1
bys PANEL: egen `x'_L1_post_m = mean(`x') if asfaras_l1 == 1 & PANEL >= 0 & male == 1
bys PANEL: egen `x'_L1_pre_m = mean(`x') if asfaras_l1 == 1 & PANEL < 0 & male == 1
bys PANEL: egen `x'_L2_post_m = mean(`x') if asfaras_l2 == 1 & PANEL >= 0 & male == 1
bys PANEL: egen `x'_L2_pre_m = mean(`x') if asfaras_l2 == 1 & PANEL < 0 & male == 1

bys PANEL: egen `x'_L0_post_f = mean(`x') if asfaras_l0 == 1 & PANEL >= 0 & male == 0
bys PANEL: egen `x'_L0_pre_f = mean(`x') if asfaras_l0 == 1 & PANEL < 0 & male == 0
bys PANEL: egen `x'_L1_post_f = mean(`x') if asfaras_l1 == 1 & PANEL >= 0 & male == 0
bys PANEL: egen `x'_L1_pre_f = mean(`x') if asfaras_l1 == 1 & PANEL < 0 & male == 0
bys PANEL: egen `x'_L2_post_f = mean(`x') if asfaras_l2 == 1 & PANEL >= 0 & male == 0
bys PANEL: egen `x'_L2_pre_f = mean(`x') if asfaras_l2 == 1 & PANEL < 0 & male == 0
sum `x'_L0_pre_m `x'_L1_pre_m `x'_L2_pre_m `x'_L0_pre_f `x'_L1_pre_f `x'_L2_pre_f  if PANEL == -1
sum `x'_L0_post_m `x'_L1_post_m `x'_L2_post_m `x'_L0_post_f `x'_L1_post_f `x'_L2_post_f if PANEL == 5
twoway (lfit `x'_L2_pre_f PANEL, mcolor(maroon) lc(maroon) lpattern(line)) (lfit `x'_L2_post_f PANEL, mcolor(maroon) lc(maroon) lpattern(line)) (lfit `x'_L2_pre_m PANEL, mcolor(maroon) lc(maroon) lpattern(dash_dot)) (lfit `x'_L2_post_m PANEL, mcolor(maroon) lc(maroon) lpattern(dash_dot)) (lfit `x'_L1_pre_f PANEL, mcolor(blue) xline(0) lc(blue) legend(position(3)) lpattern(line)) (lfit `x'_L1_post_f PANEL, mcolor(blue) xline(0) lc(blue) lpattern(line)) (lfit `x'_L1_pre_m PANEL, mcolor(blue) xline(0) lc(blue) legend(position(3)) lpattern(dash)) (lfit `x'_L1_post_m PANEL, mcolor(blue) xline(0) lc(blue) lpattern(dash)) (lfit `x'_L0_pre_f PANEL, mcolor(black) lc(black) lpattern(line)) (lfit `x'_L0_post_f PANEL, mcolor(black) lc(black) lpattern(line)) (lfit `x'_L0_pre_m PANEL, mcolor(black) lc(black) lpattern(shortdash))  (lfit `x'_L0_post_m PANEL, mcolor(black) lc(black) lpattern(shortdash)) , legend(label(1 "F: Level 2") label(2 "F: Level 2") label(3 "M: Level 2") label(4 "M: Level 2") label(5 "F: Level 1") label(6 "F: Level 1") label(7 "M: Level 1") label(8 "M: Level 1") label(9 "F: Candidate") label(10 "F: Candidate") label(11 "M: Candidate") label(12 "M: Candidate")) ytitle("`x'") xtitle("Panel")
restore 
}
}

	***************************
	**  S3 FIGURE (Panel A)  **
	***************************
{	
clear all
set more off
use "$dir\Descriptive Data for replication.dta"
sort researcher_id year
br researcher_id year level L0female_L1malereferet portfolio_l0l1 PANEL_L0 PANEL_L1
gen group = 1 if asfaras_l0_f == 1 // female as far as L0
replace group = 2 if portfolio_l0l1 & gender == 1 // male as far as L1, but trace around L0
replace group = 3 if portfolio_l0l1 & gender == 2 // female as far as L1, but trace around L0
replace group = 4 if asfaras_l0 == 1 & gender == 1 // male as far as L0 
drop if group == .
gen PANEL = PANEL_L0 if group == 1
replace PANEL = PANEL_L0 if group == 2
replace PANEL = PANEL_L0 if group == 3
replace PANEL = PANEL_L0 if group == 4
foreach x in cum_pubs { 
preserve
bys PANEL: egen `x'_L01 = mean(`x') if group == 1
bys PANEL: egen `x'_L02 = mean(`x') if group == 2
bys PANEL: egen `x'_L03 = mean(`x') if group == 3
bys PANEL: egen `x'_L04 = mean(`x') if group == 4
keep if PANEL >= -5 & PANEL <= 5
sum `x'_L03 `x'_L02 `x'_L01 `x'_L04 if PANEL == -1
twoway (connected `x'_L03 PANEL, mcolor(black) xline(0) lc(black) legend(position(6))) (connected `x'_L02 PANEL, mcolor(blue) xline(0) lc(blue) legend(position(6))) (connected `x'_L01 PANEL, mcolor(black) xline(0) lc(black) lpattern(dash) legend(position(6))) (connected `x'_L04 PANEL, mcolor(blue) xline(0) lc(blue) lpattern(dash) legend(position(6))) , legend(label(1 "F: As far as L1, but trace at L0") label(2 "M: As far as L1, but trace at L0") label(3 "F: As far as L0") label(4 "M: As far as L0")) ytitle("Total Publications") xtitle("L0 Panel")
restore
}
}

	***************************
	**  S3 FIGURE (Panel B)  **
	***************************
{
clear all
set more off
use "$dir\Descriptive Data for replication.dta"
sort researcher_id year
br researcher_id year level L0female_L1malereferet portfolio_l0l1 PANEL_L0 PANEL_L1
drop if year < 1991
gen group = 1 if asfaras_l1_f == 1 // female as far as L1
replace group = 2 if asfaras_l2_m == 1 // male as far as L2, but trace around L1
replace group = 3 if asfaras_l2_f == 1 // female as far as L2, but trace around L1
replace group = 4 if asfaras_l1_m == 1 // male as far as L1 
drop if group == .
gen PANEL = PANEL_L1 if group == 1
replace PANEL = PANEL_L1 if group == 2
replace PANEL = PANEL_L1 if group == 3
replace PANEL = PANEL_L1 if group == 4
foreach x in cum_pubs { 
preserve
bys PANEL: egen `x'_L01 = mean(`x') if group == 1
bys PANEL: egen `x'_L02 = mean(`x') if group == 2
bys PANEL: egen `x'_L03 = mean(`x') if group == 3
bys PANEL: egen `x'_L04 = mean(`x') if group == 4
keep if PANEL >= -5 & PANEL <= 5
sum `x'_L03 `x'_L02 `x'_L01 `x'_L04 if PANEL == -1
twoway (connected `x'_L03 PANEL, mcolor(black) xline(0) lc(black) legend(position(6))) (connected `x'_L02 PANEL, mcolor(blue) xline(0) lc(blue) legend(position(6))) (connected `x'_L01 PANEL, mcolor(black) xline(0) lc(black) lpattern(dash) legend(position(6))) (connected `x'_L04 PANEL, mcolor(blue) xline(0) lc(blue) lpattern(dash) legend(position(6))) , legend(label(1 "F: As far as L2, but trace at L1") label(2 "M: As far as L2, but trace at L1") label(3 "F: As far as L1") label(4 "M: As far as L1")) ytitle("Total Publications") xtitle("L1 Panel")
restore
}
}

	***************************
	**  S3 FIGURE (Panel C)  **
	***************************
{	
clear all
set more off
use "$dir\Descriptive Data for replication.dta"
sort researcher_id year
br researcher_id year level L0female_L1malereferet portfolio_l0l1 PANEL_L0 PANEL_L1
drop if year < 1991
gen group = 1 if asfaras_l2_f == 1 // female as far as L2
replace group = 2 if asfaras_l3_m == 1 // male as far as L3, but trace around L2
replace group = 3 if asfaras_l3_f == 1 // female as far as L3, but trace around L2
replace group = 4 if asfaras_l2_m == 1 // male as far as L2 
drop if group == .
gen PANEL = PANEL_L1 if group == 1
replace PANEL = PANEL_L1 if group == 2
replace PANEL = PANEL_L1 if group == 3
replace PANEL = PANEL_L1 if group == 4
foreach x in cum_pubs { 
preserve
bys PANEL: egen `x'_L01 = mean(`x') if group == 1
bys PANEL: egen `x'_L02 = mean(`x') if group == 2
bys PANEL: egen `x'_L03 = mean(`x') if group == 3
bys PANEL: egen `x'_L04 = mean(`x') if group == 4
keep if PANEL >= -5 & PANEL <= 5
sum `x'_L03 `x'_L02 `x'_L01 `x'_L04 if PANEL == -1
twoway (connected `x'_L03 PANEL, mcolor(black) xline(0) lc(black) legend(position(6))) (connected `x'_L02 PANEL, mcolor(blue) xline(0) lc(blue) legend(position(6))) (connected `x'_L01 PANEL, mcolor(black) xline(0) lc(black) lpattern(dash) legend(position(6))) (connected `x'_L04 PANEL, mcolor(blue) xline(0) lc(blue) lpattern(dash) legend(position(6))) , legend(label(1 "F: As far as L3, but trace at L2") label(2 "M: As far as L3, but trace at L2") label(3 "F: As far as L2") label(4 "M: As far as L2")) ytitle("Total Publications") xtitle("L2 Panel")
restore
}
}
	
	**************************
	**  S4 FIGURE (Panel A) **
	**************************
{	
clear all 
set more off 
use "$dir\Trend Lines for replication.dta"	
foreach x in cum_pubs { 
keep if entryyear <=2000 // SNI ENTRY BEFORE 2001
bys PANEL: egen `x'_L0_post_m = mean(`x') if asfaras_l0 == 1 & PANEL >= 0 & male == 1
bys PANEL: egen `x'_L0_pre_m = mean(`x') if asfaras_l0 == 1 & PANEL < 0 & male == 1
bys PANEL: egen `x'_L1_post_m = mean(`x') if asfaras_l1 == 1 & PANEL >= 0 & male == 1
bys PANEL: egen `x'_L1_pre_m = mean(`x') if asfaras_l1 == 1 & PANEL < 0 & male == 1
bys PANEL: egen `x'_L2_post_m = mean(`x') if asfaras_l2 == 1 & PANEL >= 0 & male == 1
bys PANEL: egen `x'_L2_pre_m = mean(`x') if asfaras_l2 == 1 & PANEL < 0 & male == 1

bys PANEL: egen `x'_L0_post_f = mean(`x') if asfaras_l0 == 1 & PANEL >= 0 & male == 0
bys PANEL: egen `x'_L0_pre_f = mean(`x') if asfaras_l0 == 1 & PANEL < 0 & male == 0
bys PANEL: egen `x'_L1_post_f = mean(`x') if asfaras_l1 == 1 & PANEL >= 0 & male == 0
bys PANEL: egen `x'_L1_pre_f = mean(`x') if asfaras_l1 == 1 & PANEL < 0 & male == 0
bys PANEL: egen `x'_L2_post_f = mean(`x') if asfaras_l2 == 1 & PANEL >= 0 & male == 0
bys PANEL: egen `x'_L2_pre_f = mean(`x') if asfaras_l2 == 1 & PANEL < 0 & male == 0

sum `x'_L0_pre_m `x'_L1_pre_m `x'_L2_pre_m `x'_L0_pre_f `x'_L1_pre_f `x'_L2_pre_f  if PANEL == -1
sum `x'_L0_post_m `x'_L1_post_m `x'_L2_post_m `x'_L0_post_f `x'_L1_post_f `x'_L2_post_f if PANEL == 5
twoway (lfit `x'_L2_pre_f PANEL, mcolor(maroon) lc(maroon) lpattern(line)) (lfit `x'_L2_post_f PANEL, mcolor(maroon) lc(maroon) lpattern(line)) (lfit `x'_L2_pre_m PANEL, mcolor(maroon) lc(maroon) lpattern(dash_dot)) (lfit `x'_L2_post_m PANEL, mcolor(maroon) lc(maroon) lpattern(dash_dot)) (lfit `x'_L1_pre_f PANEL, mcolor(blue) xline(0) lc(blue) legend(position(3)) lpattern(line)) (lfit `x'_L1_post_f PANEL, mcolor(blue) xline(0) lc(blue) lpattern(line)) (lfit `x'_L1_pre_m PANEL, mcolor(blue) xline(0) lc(blue) legend(position(3)) lpattern(dash)) (lfit `x'_L1_post_m PANEL, mcolor(blue) xline(0) lc(blue) lpattern(dash)) (lfit `x'_L0_pre_f PANEL, mcolor(black) lc(black) lpattern(line)) (lfit `x'_L0_post_f PANEL, mcolor(black) lc(black) lpattern(line)) (lfit `x'_L0_pre_m PANEL, mcolor(black) lc(black) lpattern(shortdash))  (lfit `x'_L0_post_m PANEL, mcolor(black) lc(black) lpattern(shortdash)) , legend(label(1 "F: Level 2") label(2 "F: Level 2") label(3 "M: Level 2") label(4 "M: Level 2") label(5 "F: Level 1") label(6 "F: Level 1") label(7 "M: Level 1") label(8 "M: Level 1") label(9 "F: Candidate") label(10 "F: Candidate") label(11 "M: Candidate") label(12 "M: Candidate")) ytitle("`x'") xtitle("Panel")
}
}

	**************************
	**  S4 FIGURE (Panel B) **
	**************************
{	
clear all 
set more off 
use "$dir\Trend Lines for replication.dta"		
foreach x in cum_pubs { 
keep if entryyear > 2000 // SNI ENTRY ON OR AFTER 2001
bys PANEL: egen `x'_L0_post_m = mean(`x') if asfaras_l0 == 1 & PANEL >= 0 & male == 1
bys PANEL: egen `x'_L0_pre_m = mean(`x') if asfaras_l0 == 1 & PANEL < 0 & male == 1
bys PANEL: egen `x'_L1_post_m = mean(`x') if asfaras_l1 == 1 & PANEL >= 0 & male == 1
bys PANEL: egen `x'_L1_pre_m = mean(`x') if asfaras_l1 == 1 & PANEL < 0 & male == 1
bys PANEL: egen `x'_L2_post_m = mean(`x') if asfaras_l2 == 1 & PANEL >= 0 & male == 1
bys PANEL: egen `x'_L2_pre_m = mean(`x') if asfaras_l2 == 1 & PANEL < 0 & male == 1

bys PANEL: egen `x'_L0_post_f = mean(`x') if asfaras_l0 == 1 & PANEL >= 0 & male == 0
bys PANEL: egen `x'_L0_pre_f = mean(`x') if asfaras_l0 == 1 & PANEL < 0 & male == 0
bys PANEL: egen `x'_L1_post_f = mean(`x') if asfaras_l1 == 1 & PANEL >= 0 & male == 0
bys PANEL: egen `x'_L1_pre_f = mean(`x') if asfaras_l1 == 1 & PANEL < 0 & male == 0
bys PANEL: egen `x'_L2_post_f = mean(`x') if asfaras_l2 == 1 & PANEL >= 0 & male == 0
bys PANEL: egen `x'_L2_pre_f = mean(`x') if asfaras_l2 == 1 & PANEL < 0 & male == 0

sum `x'_L0_pre_m `x'_L1_pre_m `x'_L2_pre_m `x'_L0_pre_f `x'_L1_pre_f `x'_L2_pre_f  if PANEL == -1
sum `x'_L0_post_m `x'_L1_post_m `x'_L2_post_m `x'_L0_post_f `x'_L1_post_f `x'_L2_post_f if PANEL == 5
twoway (lfit `x'_L2_pre_f PANEL, mcolor(maroon) lc(maroon) lpattern(line)) (lfit `x'_L2_post_f PANEL, mcolor(maroon) lc(maroon) lpattern(line)) (lfit `x'_L2_pre_m PANEL, mcolor(maroon) lc(maroon) lpattern(dash_dot)) (lfit `x'_L2_post_m PANEL, mcolor(maroon) lc(maroon) lpattern(dash_dot)) (lfit `x'_L1_pre_f PANEL, mcolor(blue) xline(0) lc(blue) legend(position(3)) lpattern(line)) (lfit `x'_L1_post_f PANEL, mcolor(blue) xline(0) lc(blue) lpattern(line)) (lfit `x'_L1_pre_m PANEL, mcolor(blue) xline(0) lc(blue) legend(position(3)) lpattern(dash)) (lfit `x'_L1_post_m PANEL, mcolor(blue) xline(0) lc(blue) lpattern(dash)) (lfit `x'_L0_pre_f PANEL, mcolor(black) lc(black) lpattern(line)) (lfit `x'_L0_post_f PANEL, mcolor(black) lc(black) lpattern(line)) (lfit `x'_L0_pre_m PANEL, mcolor(black) lc(black) lpattern(shortdash))  (lfit `x'_L0_post_m PANEL, mcolor(black) lc(black) lpattern(shortdash)) , legend(label(1 "F: Level 2") label(2 "F: Level 2") label(3 "M: Level 2") label(4 "M: Level 2") label(5 "F: Level 1") label(6 "F: Level 1") label(7 "M: Level 1") label(8 "M: Level 1") label(9 "F: Candidate") label(10 "F: Candidate") label(11 "M: Candidate") label(12 "M: Candidate")) ytitle("`x'") xtitle("Panel")
}
}

	*******************************
	**  S5 FIGURE (Panels A - E) **
	*******************************
{
clear all 
set more off 
use "$dir\Trend Lines for replication.dta"	
foreach x in cum_pubs { 
foreach area in areadummy1 areadummy2 areadummy3 areadummy6 areadummy7 { // areadummy1 ~ Panel A; areadummy2 ~ Panel B; areadummy3 ~ Panel C; areadummy6 ~ Panel D; areadummy7 ~ Panel E
preserve
keep if `area' == 1 // BY AREA DISCIPLINE
bys PANEL: egen `x'_L0_post_m = mean(`x') if asfaras_l0 == 1 & PANEL >= 0 & male == 1
bys PANEL: egen `x'_L0_pre_m = mean(`x') if asfaras_l0 == 1 & PANEL < 0 & male == 1
bys PANEL: egen `x'_L1_post_m = mean(`x') if asfaras_l1 == 1 & PANEL >= 0 & male == 1
bys PANEL: egen `x'_L1_pre_m = mean(`x') if asfaras_l1 == 1 & PANEL < 0 & male == 1
bys PANEL: egen `x'_L2_post_m = mean(`x') if asfaras_l2 == 1 & PANEL >= 0 & male == 1
bys PANEL: egen `x'_L2_pre_m = mean(`x') if asfaras_l2 == 1 & PANEL < 0 & male == 1

bys PANEL: egen `x'_L0_post_f = mean(`x') if asfaras_l0 == 1 & PANEL >= 0 & male == 0
bys PANEL: egen `x'_L0_pre_f = mean(`x') if asfaras_l0 == 1 & PANEL < 0 & male == 0
bys PANEL: egen `x'_L1_post_f = mean(`x') if asfaras_l1 == 1 & PANEL >= 0 & male == 0
bys PANEL: egen `x'_L1_pre_f = mean(`x') if asfaras_l1 == 1 & PANEL < 0 & male == 0
bys PANEL: egen `x'_L2_post_f = mean(`x') if asfaras_l2 == 1 & PANEL >= 0 & male == 0
bys PANEL: egen `x'_L2_pre_f = mean(`x') if asfaras_l2 == 1 & PANEL < 0 & male == 0

sum `x'_L0_pre_m `x'_L1_pre_m `x'_L2_pre_m `x'_L0_pre_f `x'_L1_pre_f `x'_L2_pre_f  if PANEL == -1
sum `x'_L0_post_m `x'_L1_post_m `x'_L2_post_m `x'_L0_post_f `x'_L1_post_f `x'_L2_post_f if PANEL == 5
twoway (lfit `x'_L2_pre_f PANEL, mcolor(maroon) lc(maroon) lpattern(line)) (lfit `x'_L2_post_f PANEL, mcolor(maroon) lc(maroon) lpattern(line)) (lfit `x'_L2_pre_m PANEL, mcolor(maroon) lc(maroon) lpattern(dash_dot)) (lfit `x'_L2_post_m PANEL, mcolor(maroon) lc(maroon) lpattern(dash_dot)) (lfit `x'_L1_pre_f PANEL, mcolor(blue) xline(0) lc(blue) legend(position(3)) lpattern(line)) (lfit `x'_L1_post_f PANEL, mcolor(blue) xline(0) lc(blue) lpattern(line)) (lfit `x'_L1_pre_m PANEL, mcolor(blue) xline(0) lc(blue) legend(position(3)) lpattern(dash)) (lfit `x'_L1_post_m PANEL, mcolor(blue) xline(0) lc(blue) lpattern(dash)) (lfit `x'_L0_pre_f PANEL, mcolor(black) lc(black) lpattern(line)) (lfit `x'_L0_post_f PANEL, mcolor(black) lc(black) lpattern(line)) (lfit `x'_L0_pre_m PANEL, mcolor(black) lc(black) lpattern(shortdash))  (lfit `x'_L0_post_m PANEL, mcolor(black) lc(black) lpattern(shortdash)) , legend(label(1 "F: Level 2") label(2 "F: Level 2") label(3 "M: Level 2") label(4 "M: Level 2") label(5 "F: Level 1") label(6 "F: Level 1") label(7 "M: Level 1") label(8 "M: Level 1") label(9 "F: Candidate") label(10 "F: Candidate") label(11 "M: Candidate") label(12 "M: Candidate")) ytitle("Total Publications") xtitle("Panel")
restore 
}
}
}

	**************************
	**  S6 FIGURE (Panel A) **
	**************************
{
clear all 
set more off 
use "$dir\Trend Lines for replication.dta"	
foreach x in cum_pubs { 
keep if dumphdmex == 1 // MEXICAN PHD
bys PANEL: egen `x'_L0_post_m = mean(`x') if asfaras_l0 == 1 & PANEL >= 0 & male == 1
bys PANEL: egen `x'_L0_pre_m = mean(`x') if asfaras_l0 == 1 & PANEL < 0 & male == 1
bys PANEL: egen `x'_L1_post_m = mean(`x') if asfaras_l1 == 1 & PANEL >= 0 & male == 1
bys PANEL: egen `x'_L1_pre_m = mean(`x') if asfaras_l1 == 1 & PANEL < 0 & male == 1
bys PANEL: egen `x'_L2_post_m = mean(`x') if asfaras_l2 == 1 & PANEL >= 0 & male == 1
bys PANEL: egen `x'_L2_pre_m = mean(`x') if asfaras_l2 == 1 & PANEL < 0 & male == 1

bys PANEL: egen `x'_L0_post_f = mean(`x') if asfaras_l0 == 1 & PANEL >= 0 & male == 0
bys PANEL: egen `x'_L0_pre_f = mean(`x') if asfaras_l0 == 1 & PANEL < 0 & male == 0
bys PANEL: egen `x'_L1_post_f = mean(`x') if asfaras_l1 == 1 & PANEL >= 0 & male == 0
bys PANEL: egen `x'_L1_pre_f = mean(`x') if asfaras_l1 == 1 & PANEL < 0 & male == 0
bys PANEL: egen `x'_L2_post_f = mean(`x') if asfaras_l2 == 1 & PANEL >= 0 & male == 0
bys PANEL: egen `x'_L2_pre_f = mean(`x') if asfaras_l2 == 1 & PANEL < 0 & male == 0

sum `x'_L0_pre_m `x'_L1_pre_m `x'_L2_pre_m `x'_L0_pre_f `x'_L1_pre_f `x'_L2_pre_f  if PANEL == -1
sum `x'_L0_post_m `x'_L1_post_m `x'_L2_post_m `x'_L0_post_f `x'_L1_post_f `x'_L2_post_f if PANEL == 5
twoway (lfit `x'_L2_pre_f PANEL, mcolor(maroon) lc(maroon) lpattern(line)) (lfit `x'_L2_post_f PANEL, mcolor(maroon) lc(maroon) lpattern(line)) (lfit `x'_L2_pre_m PANEL, mcolor(maroon) lc(maroon) lpattern(dash_dot)) (lfit `x'_L2_post_m PANEL, mcolor(maroon) lc(maroon) lpattern(dash_dot)) (lfit `x'_L1_pre_f PANEL, mcolor(blue) xline(0) lc(blue) legend(position(3)) lpattern(line)) (lfit `x'_L1_post_f PANEL, mcolor(blue) xline(0) lc(blue) lpattern(line)) (lfit `x'_L1_pre_m PANEL, mcolor(blue) xline(0) lc(blue) legend(position(3)) lpattern(dash)) (lfit `x'_L1_post_m PANEL, mcolor(blue) xline(0) lc(blue) lpattern(dash)) (lfit `x'_L0_pre_f PANEL, mcolor(black) lc(black) lpattern(line)) (lfit `x'_L0_post_f PANEL, mcolor(black) lc(black) lpattern(line)) (lfit `x'_L0_pre_m PANEL, mcolor(black) lc(black) lpattern(shortdash))  (lfit `x'_L0_post_m PANEL, mcolor(black) lc(black) lpattern(shortdash)) , legend(label(1 "F: Level 2") label(2 "F: Level 2") label(3 "M: Level 2") label(4 "M: Level 2") label(5 "F: Level 1") label(6 "F: Level 1") label(7 "M: Level 1") label(8 "M: Level 1") label(9 "F: Candidate") label(10 "F: Candidate") label(11 "M: Candidate") label(12 "M: Candidate")) ytitle("Total Publications") xtitle("Panel")
restore 
}
}

	**************************
	**  S6 FIGURE (Panel B) **
	**************************
{
clear all 
set more off 
use "$dir\Trend Lines for replication.dta"	
foreach x in cum_pubs { 
preserve 
drop if dumphdmex == 1 // FOREIGN PHD
bys PANEL: egen `x'_L0_post_m = mean(`x') if asfaras_l0 == 1 & PANEL >= 0 & male == 1
bys PANEL: egen `x'_L0_pre_m = mean(`x') if asfaras_l0 == 1 & PANEL < 0 & male == 1
bys PANEL: egen `x'_L1_post_m = mean(`x') if asfaras_l1 == 1 & PANEL >= 0 & male == 1
bys PANEL: egen `x'_L1_pre_m = mean(`x') if asfaras_l1 == 1 & PANEL < 0 & male == 1
bys PANEL: egen `x'_L2_post_m = mean(`x') if asfaras_l2 == 1 & PANEL >= 0 & male == 1
bys PANEL: egen `x'_L2_pre_m = mean(`x') if asfaras_l2 == 1 & PANEL < 0 & male == 1

bys PANEL: egen `x'_L0_post_f = mean(`x') if asfaras_l0 == 1 & PANEL >= 0 & male == 0
bys PANEL: egen `x'_L0_pre_f = mean(`x') if asfaras_l0 == 1 & PANEL < 0 & male == 0
bys PANEL: egen `x'_L1_post_f = mean(`x') if asfaras_l1 == 1 & PANEL >= 0 & male == 0
bys PANEL: egen `x'_L1_pre_f = mean(`x') if asfaras_l1 == 1 & PANEL < 0 & male == 0
bys PANEL: egen `x'_L2_post_f = mean(`x') if asfaras_l2 == 1 & PANEL >= 0 & male == 0
bys PANEL: egen `x'_L2_pre_f = mean(`x') if asfaras_l2 == 1 & PANEL < 0 & male == 0

sum `x'_L0_pre_m `x'_L1_pre_m `x'_L2_pre_m `x'_L0_pre_f `x'_L1_pre_f `x'_L2_pre_f  if PANEL == -1
sum `x'_L0_post_m `x'_L1_post_m `x'_L2_post_m `x'_L0_post_f `x'_L1_post_f `x'_L2_post_f if PANEL == 5
twoway (lfit `x'_L2_pre_f PANEL, mcolor(maroon) lc(maroon) lpattern(line)) (lfit `x'_L2_post_f PANEL, mcolor(maroon) lc(maroon) lpattern(line)) (lfit `x'_L2_pre_m PANEL, mcolor(maroon) lc(maroon) lpattern(dash_dot)) (lfit `x'_L2_post_m PANEL, mcolor(maroon) lc(maroon) lpattern(dash_dot)) (lfit `x'_L1_pre_f PANEL, mcolor(blue) xline(0) lc(blue) legend(position(3)) lpattern(line)) (lfit `x'_L1_post_f PANEL, mcolor(blue) xline(0) lc(blue) lpattern(line)) (lfit `x'_L1_pre_m PANEL, mcolor(blue) xline(0) lc(blue) legend(position(3)) lpattern(dash)) (lfit `x'_L1_post_m PANEL, mcolor(blue) xline(0) lc(blue) lpattern(dash)) (lfit `x'_L0_pre_f PANEL, mcolor(black) lc(black) lpattern(line)) (lfit `x'_L0_post_f PANEL, mcolor(black) lc(black) lpattern(line)) (lfit `x'_L0_pre_m PANEL, mcolor(black) lc(black) lpattern(shortdash))  (lfit `x'_L0_post_m PANEL, mcolor(black) lc(black) lpattern(shortdash)) , legend(label(1 "F: Level 2") label(2 "F: Level 2") label(3 "M: Level 2") label(4 "M: Level 2") label(5 "F: Level 1") label(6 "F: Level 1") label(7 "M: Level 1") label(8 "M: Level 1") label(9 "F: Candidate") label(10 "F: Candidate") label(11 "M: Candidate") label(12 "M: Candidate")) ytitle("`x'") xtitle("Panel")
restore 
}
}

	**************************
	**  S7 FIGURE (Panel A) **
	**************************
{
clear all 
set more off 
use "$dir\Trend Lines for replication.dta"	
foreach x in cum_pubs { 
preserve 
keep if largeinst == 1 // LARGE INSTITUTION
bys PANEL: egen `x'_L0_post_m = mean(`x') if asfaras_l0 == 1 & PANEL >= 0 & male == 1
bys PANEL: egen `x'_L0_pre_m = mean(`x') if asfaras_l0 == 1 & PANEL < 0 & male == 1
bys PANEL: egen `x'_L1_post_m = mean(`x') if asfaras_l1 == 1 & PANEL >= 0 & male == 1
bys PANEL: egen `x'_L1_pre_m = mean(`x') if asfaras_l1 == 1 & PANEL < 0 & male == 1
bys PANEL: egen `x'_L2_post_m = mean(`x') if asfaras_l2 == 1 & PANEL >= 0 & male == 1
bys PANEL: egen `x'_L2_pre_m = mean(`x') if asfaras_l2 == 1 & PANEL < 0 & male == 1

bys PANEL: egen `x'_L0_post_f = mean(`x') if asfaras_l0 == 1 & PANEL >= 0 & male == 0
bys PANEL: egen `x'_L0_pre_f = mean(`x') if asfaras_l0 == 1 & PANEL < 0 & male == 0
bys PANEL: egen `x'_L1_post_f = mean(`x') if asfaras_l1 == 1 & PANEL >= 0 & male == 0
bys PANEL: egen `x'_L1_pre_f = mean(`x') if asfaras_l1 == 1 & PANEL < 0 & male == 0
bys PANEL: egen `x'_L2_post_f = mean(`x') if asfaras_l2 == 1 & PANEL >= 0 & male == 0
bys PANEL: egen `x'_L2_pre_f = mean(`x') if asfaras_l2 == 1 & PANEL < 0 & male == 0

sum `x'_L0_pre_m `x'_L1_pre_m `x'_L2_pre_m `x'_L0_pre_f `x'_L1_pre_f `x'_L2_pre_f  if PANEL == -1
sum `x'_L0_post_m `x'_L1_post_m `x'_L2_post_m `x'_L0_post_f `x'_L1_post_f `x'_L2_post_f if PANEL == 5
twoway (lfit `x'_L2_pre_f PANEL, mcolor(maroon) lc(maroon) lpattern(line)) (lfit `x'_L2_post_f PANEL, mcolor(maroon) lc(maroon) lpattern(line)) (lfit `x'_L2_pre_m PANEL, mcolor(maroon) lc(maroon) lpattern(dash_dot)) (lfit `x'_L2_post_m PANEL, mcolor(maroon) lc(maroon) lpattern(dash_dot)) (lfit `x'_L1_pre_f PANEL, mcolor(blue) xline(0) lc(blue) legend(position(3)) lpattern(line)) (lfit `x'_L1_post_f PANEL, mcolor(blue) xline(0) lc(blue) lpattern(line)) (lfit `x'_L1_pre_m PANEL, mcolor(blue) xline(0) lc(blue) legend(position(3)) lpattern(dash)) (lfit `x'_L1_post_m PANEL, mcolor(blue) xline(0) lc(blue) lpattern(dash)) (lfit `x'_L0_pre_f PANEL, mcolor(black) lc(black) lpattern(line)) (lfit `x'_L0_post_f PANEL, mcolor(black) lc(black) lpattern(line)) (lfit `x'_L0_pre_m PANEL, mcolor(black) lc(black) lpattern(shortdash))  (lfit `x'_L0_post_m PANEL, mcolor(black) lc(black) lpattern(shortdash)) , legend(label(1 "F: Level 2") label(2 "F: Level 2") label(3 "M: Level 2") label(4 "M: Level 2") label(5 "F: Level 1") label(6 "F: Level 1") label(7 "M: Level 1") label(8 "M: Level 1") label(9 "F: Candidate") label(10 "F: Candidate") label(11 "M: Candidate") label(12 "M: Candidate")) ytitle("`x'") xtitle("Panel")
restore 
}
}

	**************************
	**  S7 FIGURE (Panel B) **
	**************************
{
clear all 
set more off 
use "$dir\Trend Lines for replication.dta"	
foreach x in cum_pubs { 
preserve 
keep if largeinst == 0 // SMALL INSTITUTION
bys PANEL: egen `x'_L0_post_m = mean(`x') if asfaras_l0 == 1 & PANEL >= 0 & male == 1
bys PANEL: egen `x'_L0_pre_m = mean(`x') if asfaras_l0 == 1 & PANEL < 0 & male == 1
bys PANEL: egen `x'_L1_post_m = mean(`x') if asfaras_l1 == 1 & PANEL >= 0 & male == 1
bys PANEL: egen `x'_L1_pre_m = mean(`x') if asfaras_l1 == 1 & PANEL < 0 & male == 1
bys PANEL: egen `x'_L2_post_m = mean(`x') if asfaras_l2 == 1 & PANEL >= 0 & male == 1
bys PANEL: egen `x'_L2_pre_m = mean(`x') if asfaras_l2 == 1 & PANEL < 0 & male == 1

bys PANEL: egen `x'_L0_post_f = mean(`x') if asfaras_l0 == 1 & PANEL >= 0 & male == 0
bys PANEL: egen `x'_L0_pre_f = mean(`x') if asfaras_l0 == 1 & PANEL < 0 & male == 0
bys PANEL: egen `x'_L1_post_f = mean(`x') if asfaras_l1 == 1 & PANEL >= 0 & male == 0
bys PANEL: egen `x'_L1_pre_f = mean(`x') if asfaras_l1 == 1 & PANEL < 0 & male == 0
bys PANEL: egen `x'_L2_post_f = mean(`x') if asfaras_l2 == 1 & PANEL >= 0 & male == 0
bys PANEL: egen `x'_L2_pre_f = mean(`x') if asfaras_l2 == 1 & PANEL < 0 & male == 0

sum `x'_L0_pre_m `x'_L1_pre_m `x'_L2_pre_m `x'_L0_pre_f `x'_L1_pre_f `x'_L2_pre_f  if PANEL == -1
sum `x'_L0_post_m `x'_L1_post_m `x'_L2_post_m `x'_L0_post_f `x'_L1_post_f `x'_L2_post_f if PANEL == 5
twoway (lfit `x'_L2_pre_f PANEL, mcolor(maroon) lc(maroon) lpattern(line)) (lfit `x'_L2_post_f PANEL, mcolor(maroon) lc(maroon) lpattern(line)) (lfit `x'_L2_pre_m PANEL, mcolor(maroon) lc(maroon) lpattern(dash_dot)) (lfit `x'_L2_post_m PANEL, mcolor(maroon) lc(maroon) lpattern(dash_dot)) (lfit `x'_L1_pre_f PANEL, mcolor(blue) xline(0) lc(blue) legend(position(3)) lpattern(line)) (lfit `x'_L1_post_f PANEL, mcolor(blue) xline(0) lc(blue) lpattern(line)) (lfit `x'_L1_pre_m PANEL, mcolor(blue) xline(0) lc(blue) legend(position(3)) lpattern(dash)) (lfit `x'_L1_post_m PANEL, mcolor(blue) xline(0) lc(blue) lpattern(dash)) (lfit `x'_L0_pre_f PANEL, mcolor(black) lc(black) lpattern(line)) (lfit `x'_L0_post_f PANEL, mcolor(black) lc(black) lpattern(line)) (lfit `x'_L0_pre_m PANEL, mcolor(black) lc(black) lpattern(shortdash))  (lfit `x'_L0_post_m PANEL, mcolor(black) lc(black) lpattern(shortdash)) , legend(label(1 "F: Level 2") label(2 "F: Level 2") label(3 "M: Level 2") label(4 "M: Level 2") label(5 "F: Level 1") label(6 "F: Level 1") label(7 "M: Level 1") label(8 "M: Level 1") label(9 "F: Candidate") label(10 "F: Candidate") label(11 "M: Candidate") label(12 "M: Candidate")) ytitle("`x'") xtitle("Panel")
restore 
}
}

	*************************
	**  FIGURE 5 (Panel A) **
	*************************
{
clear all 
set more off 
use "$dir\Trend Lines for replication.dta"		
foreach x in cum_pubs { 
preserve
keep if review_committee_male100pct == 1 // LIKELIHOOD OF WOMEN ON REVIEW PANEL (0 PERCENT)
bys PANEL: egen `x'_L0_post_m = mean(`x') if level == "L0" & PANEL >= 0 & male == 1
bys PANEL: egen `x'_L0_pre_m = mean(`x') if level == "L0" & PANEL < 0 & male == 1
bys PANEL: egen `x'_L1_post_m = mean(`x') if level == "L1" & PANEL >= 0 & male == 1
bys PANEL: egen `x'_L1_pre_m = mean(`x') if level == "L1" & PANEL < 0 & male == 1
bys PANEL: egen `x'_L2_post_m = mean(`x') if level == "L2" & PANEL >= 0 & male == 1
bys PANEL: egen `x'_L2_pre_m = mean(`x') if level == "L2" & PANEL < 0 & male == 1

bys PANEL: egen `x'_L0_post_f = mean(`x') if level == "L0" & PANEL >= 0 & male == 0
bys PANEL: egen `x'_L0_pre_f = mean(`x') if level == "L0" & PANEL < 0 & male == 0
bys PANEL: egen `x'_L1_post_f = mean(`x') if level == "L1" & PANEL >= 0 & male == 0
bys PANEL: egen `x'_L1_pre_f = mean(`x') if level == "L1" & PANEL < 0 & male == 0
bys PANEL: egen `x'_L2_post_f = mean(`x') if level == "L2" & PANEL >= 0 & male == 0
bys PANEL: egen `x'_L2_pre_f = mean(`x') if level == "L2" & PANEL < 0 & male == 0

twoway (lfit `x'_L2_pre_f PANEL, mcolor(maroon) lc(maroon) lpattern(line)) (lfit `x'_L2_post_f PANEL, mcolor(maroon) lc(maroon) lpattern(line)) (lfit `x'_L2_pre_m PANEL, mcolor(maroon) lc(maroon) lpattern(dash_dot)) (lfit `x'_L2_post_m PANEL, mcolor(maroon) lc(maroon) lpattern(dash_dot)) (lfit `x'_L1_pre_f PANEL, mcolor(blue) xline(0) lc(blue) legend(position(3)) lpattern(line)) (lfit `x'_L1_post_f PANEL, mcolor(blue) xline(0) lc(blue) lpattern(line)) (lfit `x'_L1_pre_m PANEL, mcolor(blue) xline(0) lc(blue) legend(position(3)) lpattern(dash)) (lfit `x'_L1_post_m PANEL, mcolor(blue) xline(0) lc(blue) lpattern(dash)) (lfit `x'_L0_pre_f PANEL, mcolor(black) lc(black) lpattern(line)) (lfit `x'_L0_post_f PANEL, mcolor(black) lc(black) lpattern(line)) (lfit `x'_L0_pre_m PANEL, mcolor(black) lc(black) lpattern(shortdash))  (lfit `x'_L0_post_m PANEL, mcolor(black) lc(black) lpattern(shortdash)) , legend(label(1 "F: Level 2") label(2 "F: Level 2") label(3 "M: Level 2") label(4 "M: Level 2") label(5 "F: Level 1") label(6 "F: Level 1") label(7 "M: Level 1") label(8 "M: Level 1") label(9 "F: Candidate") label(10 "F: Candidate") label(11 "M: Candidate") label(12 "M: Candidate")) ytitle("Total Publications") xtitle("Panel")
restore 
}
}

	*************************
	**  FIGURE 5 (Panel B) **
	*************************
{
clear all 
set more off 
use "$dir\Trend Lines for replication.dta"		
foreach x in cum_pubs { 
preserve
keep if review_committee_male95pct == 1 // LIKELIHOOD OF WOMEN ON REVIEW PANEL (5 PERCENT)
bys PANEL: egen `x'_L0_post_m = mean(`x') if level == "L0" & PANEL >= 0 & male == 1
bys PANEL: egen `x'_L0_pre_m = mean(`x') if level == "L0" & PANEL < 0 & male == 1
bys PANEL: egen `x'_L1_post_m = mean(`x') if level == "L1" & PANEL >= 0 & male == 1
bys PANEL: egen `x'_L1_pre_m = mean(`x') if level == "L1" & PANEL < 0 & male == 1
bys PANEL: egen `x'_L2_post_m = mean(`x') if level == "L2" & PANEL >= 0 & male == 1
bys PANEL: egen `x'_L2_pre_m = mean(`x') if level == "L2" & PANEL < 0 & male == 1

bys PANEL: egen `x'_L0_post_f = mean(`x') if level == "L0" & PANEL >= 0 & male == 0
bys PANEL: egen `x'_L0_pre_f = mean(`x') if level == "L0" & PANEL < 0 & male == 0
bys PANEL: egen `x'_L1_post_f = mean(`x') if level == "L1" & PANEL >= 0 & male == 0
bys PANEL: egen `x'_L1_pre_f = mean(`x') if level == "L1" & PANEL < 0 & male == 0
bys PANEL: egen `x'_L2_post_f = mean(`x') if level == "L2" & PANEL >= 0 & male == 0
bys PANEL: egen `x'_L2_pre_f = mean(`x') if level == "L2" & PANEL < 0 & male == 0

twoway (lfit `x'_L2_pre_f PANEL, mcolor(maroon) lc(maroon) lpattern(line)) (lfit `x'_L2_post_f PANEL, mcolor(maroon) lc(maroon) lpattern(line)) (lfit `x'_L2_pre_m PANEL, mcolor(maroon) lc(maroon) lpattern(dash_dot)) (lfit `x'_L2_post_m PANEL, mcolor(maroon) lc(maroon) lpattern(dash_dot)) (lfit `x'_L1_pre_f PANEL, mcolor(blue) xline(0) lc(blue) legend(position(3)) lpattern(line)) (lfit `x'_L1_post_f PANEL, mcolor(blue) xline(0) lc(blue) lpattern(line)) (lfit `x'_L1_pre_m PANEL, mcolor(blue) xline(0) lc(blue) legend(position(3)) lpattern(dash)) (lfit `x'_L1_post_m PANEL, mcolor(blue) xline(0) lc(blue) lpattern(dash)) (lfit `x'_L0_pre_f PANEL, mcolor(black) lc(black) lpattern(line)) (lfit `x'_L0_post_f PANEL, mcolor(black) lc(black) lpattern(line)) (lfit `x'_L0_pre_m PANEL, mcolor(black) lc(black) lpattern(shortdash))  (lfit `x'_L0_post_m PANEL, mcolor(black) lc(black) lpattern(shortdash)) , legend(label(1 "F: Level 2") label(2 "F: Level 2") label(3 "M: Level 2") label(4 "M: Level 2") label(5 "F: Level 1") label(6 "F: Level 1") label(7 "M: Level 1") label(8 "M: Level 1") label(9 "F: Candidate") label(10 "F: Candidate") label(11 "M: Candidate") label(12 "M: Candidate")) ytitle("Total Publications") xtitle("Panel")
restore 
}
}

	*************************
	**  FIGURE 5 (Panel C) **
	*************************
{
clear all 
set more off 
use "$dir\Trend Lines for replication.dta"		
foreach x in cum_pubs { 
keep if review_committee_male90pct == 1 // LIKELIHOOD OF WOMEN ON REVIEW PANEL (10 PERCENT)
bys PANEL: egen `x'_L0_post_m = mean(`x') if level == "L0" & PANEL >= 0 & male == 1
bys PANEL: egen `x'_L0_pre_m = mean(`x') if level == "L0" & PANEL < 0 & male == 1
bys PANEL: egen `x'_L1_post_m = mean(`x') if level == "L1" & PANEL >= 0 & male == 1
bys PANEL: egen `x'_L1_pre_m = mean(`x') if level == "L1" & PANEL < 0 & male == 1
bys PANEL: egen `x'_L2_post_m = mean(`x') if level == "L2" & PANEL >= 0 & male == 1
bys PANEL: egen `x'_L2_pre_m = mean(`x') if level == "L2" & PANEL < 0 & male == 1

bys PANEL: egen `x'_L0_post_f = mean(`x') if level == "L0" & PANEL >= 0 & male == 0
bys PANEL: egen `x'_L0_pre_f = mean(`x') if level == "L0" & PANEL < 0 & male == 0
bys PANEL: egen `x'_L1_post_f = mean(`x') if level == "L1" & PANEL >= 0 & male == 0
bys PANEL: egen `x'_L1_pre_f = mean(`x') if level == "L1" & PANEL < 0 & male == 0
bys PANEL: egen `x'_L2_post_f = mean(`x') if level == "L2" & PANEL >= 0 & male == 0
bys PANEL: egen `x'_L2_pre_f = mean(`x') if level == "L2" & PANEL < 0 & male == 0

twoway (lfit `x'_L2_pre_f PANEL, mcolor(maroon) lc(maroon) lpattern(line)) (lfit `x'_L2_post_f PANEL, mcolor(maroon) lc(maroon) lpattern(line)) (lfit `x'_L2_pre_m PANEL, mcolor(maroon) lc(maroon) lpattern(dash_dot)) (lfit `x'_L2_post_m PANEL, mcolor(maroon) lc(maroon) lpattern(dash_dot)) (lfit `x'_L1_pre_f PANEL, mcolor(blue) xline(0) lc(blue) legend(position(3)) lpattern(line)) (lfit `x'_L1_post_f PANEL, mcolor(blue) xline(0) lc(blue) lpattern(line)) (lfit `x'_L1_pre_m PANEL, mcolor(blue) xline(0) lc(blue) legend(position(3)) lpattern(dash)) (lfit `x'_L1_post_m PANEL, mcolor(blue) xline(0) lc(blue) lpattern(dash)) (lfit `x'_L0_pre_f PANEL, mcolor(black) lc(black) lpattern(line)) (lfit `x'_L0_post_f PANEL, mcolor(black) lc(black) lpattern(line)) (lfit `x'_L0_pre_m PANEL, mcolor(black) lc(black) lpattern(shortdash))  (lfit `x'_L0_post_m PANEL, mcolor(black) lc(black) lpattern(shortdash)) , legend(label(1 "F: Level 2") label(2 "F: Level 2") label(3 "M: Level 2") label(4 "M: Level 2") label(5 "F: Level 1") label(6 "F: Level 1") label(7 "M: Level 1") label(8 "M: Level 1") label(9 "F: Candidate") label(10 "F: Candidate") label(11 "M: Candidate") label(12 "M: Candidate")) ytitle("Total Publications") xtitle("Panel")
}
}
	
	*********************************
	**  FIGURE 6 (DERIVE IN EXCEL) **
	*********************************
	* We construct this figure in Microsoft Excel (Excel for replication.csv). Refer to tab <T2 F1 F2 F6>.
	
	****************
	**  S8 FIGURE **
	****************
	* We construct this figure in Microsoft Excel (Excel for replication.csv). Refer to tab <S8 raw AND S8T>.
{	
clear all
set more off
/* for Author Use to set up de-identified replication code.
use "$dir\Data Prep.dta"
keep clavediscipline pubs year area cum_pubs asfaras* areadummy*
save "$dir\Data Prep for replication.dta", replace
*/
use "$dir\Data Prep for replication.dta"
br clavediscipline pubs year area
gen AREA = 1000 if areadummy1 == 1
replace AREA = 2000 if areadummy2 == 1
replace AREA = 3000 if areadummy3 == 1
replace AREA = 6000 if areadummy6 == 1
replace AREA = 7000 if areadummy7 == 1

corr area AREA
gen area_discipline = AREA + clavediscipline
drop if clavediscipline == .

foreach x in l0 l1 l2 l3 {
preserve 
drop if year < 1991
keep if asfaras_`x' == 1
collapse (mean) cum_pubs (max) area, by (area_discipline)
rename cum_pubs cum_pubs_`x' 
gen area_`x' = area
save "$dir\discipline variation_`x'.dta", replace 
restore 
}

foreach x in l0 l1 l2 l3 {
preserve 
drop if year < 1991
keep if asfaras_`x' == 1
collapse (mean) cum_pubs, by (area)
rename cum_pubs pubs_area_`x'
save "$dir\area variation_`x'.dta", replace 
restore 
}

clear all
set more off
use "$dir\discipline variation_l0.dta"
foreach x in l1 l2 l3 {
merge 1:1 area_discipline using "$dir\discipline variation_`x'.dta"
drop _merge 
}

foreach x in l0 l1 l2 l3 {
merge m:1 area using "$dir\area variation_`x'.dta"
drop _merge 
}
	
sort area_discipline
br area_discipline pubs_area_l0 cum_pubs_l0 pubs_area_l1 cum_pubs_l1 pubs_area_l2 cum_pubs_l2 pubs_area_l3 cum_pubs_l3
}
********************************************************************************
** END **
********************************************************************************